package persistence;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtil {
	private static Configuration cfg = new Configuration().configure();
	private static ServiceRegistry  sr = new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();
	private static SessionFactory factory = cfg.buildSessionFactory(sr);
	
	public static Session openSession(){
		return factory.openSession();
	}
	
	public static void closeSession(Session session){
		if(session != null){
			session.close();
		}
	}
	
	
	
}
